package com.mxchip.livestarmobile.mobile.signalling.socket.utils;



import com.alibaba.fastjson.JSON;
import com.mxchip.livestarmobile.mobile.util.Log.MyLog;

import org.json.JSONException;
import org.json.JSONObject;

/***
 *** Created by  com.duobeiyun.dbysocketclient.utils by yangge on 2018/8/23 
 *** mail:ge123.yang@gmail.com
 **/
public class JsonUtils {

    /*public static JSONObject tojson(Object o) {
        return (JSONObject) JSONObject.toJSON(o);
    }*/
    public static JSONObject tojson(Object o) {
        String s= com.alibaba.fastjson.JSONObject.toJSONString(o);
        try {
            return new JSONObject(s);
        } catch (JSONException e) {
//            e.printStackTrace();
            return null;
        }
    }

    public static <T> T toObject(String o, Class<T> clazz) {
        return JSON.parseObject(o, clazz);
    }
}
